﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Text;
using EKETEAM.UserControl;
using EKETEAM.FrameWork;
using EKETEAM.Data;

namespace EKECMS.Phone
{
    public partial class Parents : System.Web.UI.Page
    {
        public string id = "";
        public eSiteInfo siteinfo = new eSiteInfo();
        protected void Page_Load(object sender, EventArgs e)
        {
            Pub.checkPhone(); //不是手机、ipod 访问则跳转到PC版

            ((EKECMS.Master.Phone)Master).SiteInfo = siteinfo;
            Pub.clearPageCache();
            #region 安全性检查
            if (Request.QueryString["id"] == null) Response.Redirect("Default.aspx", true);
            id = Request.QueryString["id"].ToString();
            #endregion

            StringBuilder sb = new StringBuilder();
            eDataView dataview;
            string sql = "select ColumnID,mc,Type,url from " + Pub.getTablePrefix() + "Columns where ParentColumnID=" + id + " and WebCode='" + eBase.getWebCode() + "'";
            sql += " and show=1 and delTag=0 order by px,ColumnID";
            DataTable tb = eBase.DataBase.getDataTable(sql);
            foreach (DataRow dr in tb.Rows)
            {

                sb.Append("<div class=\"left_title\"><h2><a href=\"" + siteinfo.getmhref(dr["ColumnID"].ToString(), "", dr["Type"].ToString(), dr["url"].ToString()) + "\" >" + dr["mc"].ToString() + "</a></h2><span class=\"more\"><a href=\"" + siteinfo.getmhref(dr["ColumnID"].ToString(), "", dr["Type"].ToString(), dr["url"].ToString()) + "\" ><img src=\"../Plugins/mred/images/more.gif\" ></a></span></div>\r\n");
                sb.Append("<div class=\"left_body\">\r\n");

                switch (dr["Type"].ToString())
                {

                    case "1":
                        #region 单页文章
                        sb.Append(eBase.DataBase.getValue("select jj from " + Pub.getTablePrefix() + "Columns where ColumnID=" + dr["ColumnID"].ToString()));
                        #endregion
                        break;
                    case "2":
                        #region 文章列表
                        dataview = new eDataView();
                        dataview.DataID = "63dec826-5dc5-4a4a-aaf7-5a951af90dd8";
                        dataview.Where.Add("ColumnID='" + dr["ColumnID"].ToString() + "'");
                        dataview.Where.Add("WebCode='" + eBase.getWebCode() + "'");

                        sb.Append(dataview.getControlHTML());
                        #endregion
                        break;
                    case "3":
                        #region 产品栏目
                        dataview = new eDataView();
                        dataview.DataID = "9f30a478-cc8b-49de-b1b5-7f514881e016";
                        dataview.Where.Add("ColumnID='" + dr["ColumnID"].ToString() + "'");
                        dataview.Where.Add("WebCode='" + eBase.getWebCode() + "'");
                        sb.Append( dataview.getControlHTML());
                        #endregion
                        break;
                    case "4":
                        #region 图片栏目
                        dataview = new eDataView();
                        dataview.DataID = "372db4a1-6599-4bd4-ac2d-8a4db1e07041";
                        dataview.Where.Add("ColumnID='" + dr["ColumnID"].ToString() + "'");
                        dataview.Where.Add("WebCode='" + eBase.getWebCode() + "'");
                        sb.Append(dataview.getControlHTML());
                        #endregion
                        break;
                    case "5":
                        #region 案例栏目
                        dataview = new eDataView();
                        dataview.DataID = "ce314691-024e-4d0b-b864-8c9750b7d836";
                        dataview.Where.Add("ColumnID='" + dr["ColumnID"].ToString() + "'");
                        dataview.Where.Add("WebCode='" + eBase.getWebCode() + "'");
                        sb.Append( dataview.getControlHTML() );
                        #endregion
                        break;
                    case "6":
                        #region 视频栏目
                        dataview = new eDataView();
                        dataview.DataID = "f9a710bd-0f84-4ac9-a5fc-b1fe7e7e276c";
                        dataview.Where.Add("ColumnID='" + dr["ColumnID"].ToString() + "'");
                        dataview.Where.Add("WebCode='" + eBase.getWebCode() + "'");
                        sb.Append(dataview.getControlHTML() );
                        #endregion
                        break;
                    case "7":
                        #region 留言栏目
                        dataview = new eDataView();
                        dataview.DataID = "b57b267f-8b68-46ee-b040-e13a39a59f80";
                        dataview.Where.Add("ColumnID='" + dr["ColumnID"].ToString() + "'");
                        dataview.Where.Add("WebCode='" + eBase.getWebCode() + "'");
                        sb.Append( dataview.getControlHTML() );
                        #endregion
                        break;
                }
                sb.Append("</div>\r\n");
            }
            LitBody.Text = sb.ToString();
        }
    }
}